package com.ahau.springcloud.controller;

import com.ahau.springcloud.dao.PayMentDao;
import com.ahau.springcloud.entities.CommonResult;
import com.ahau.springcloud.entity.PayMent;
import com.ahau.springcloud.service.PayMentService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (PayMent)表控制层
 *
 * @author makejava
 * @since 2021-11-28 23:11:16
 */
@RestController
@RequestMapping("/payMent")
public class PayMentController {
    /**
     * 服务对象
     */
    @Value("${server.port}")
    private String serverPort;
    @Resource
    private PayMentService payMentService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectOne/{id}")
    public CommonResult selectOne(@PathVariable("id") Long id) {
        PayMent payMent = this.payMentService.queryById(id);
        if (payMent==null){
            return new CommonResult(201,"接口没错就是没有这个值,sorry我喜欢刘碟,端口号是"+serverPort,null);
        }
        return new CommonResult(200,"查询成功端口号是"+serverPort,payMent);
    }
   @PostMapping("/insert")
    public CommonResult insert(@RequestBody PayMent payMent){
       PayMent insert = payMentService.insert(payMent);
       return new CommonResult(200,"添加成功",null);
   }
    @GetMapping("/port")
    public String port(){
        return serverPort;
    }
}